package com.clone.surpassli.clone_cloudreader.utils;

import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.drawable.Drawable;

import com.clone.surpassli.clone_cloudreader.app.CloneCloudReaderApplication;

import java.util.Random;

/**
 * Created by SurpassLi on 2017/9/29.
 * CommonUtils
 */
public class CommonUtils {

    /**
     * 随机颜色
     */
    public static int randomColor() {
        Random random = new Random();
        int red = random.nextInt(150) + 50;//50-199
        int green = random.nextInt(150) + 50;//50-199
        int blue = random.nextInt(150) + 50;//50-199
        return Color.rgb(red, green, blue);
    }

    public static Drawable getDrawable(int resid) {
        return getResources().getDrawable(resid);
    }

    public static int getColor(int resId){
        return getResources().getColor(resId);
    }

    private static Resources getResources(){
        return CloneCloudReaderApplication.getInstance().getResources();
    }

    public static String getString(int resourceId) {
        return getResources().getString(resourceId);
    }

    public static float getDimens(int resId) {
        return getResources().getDimension(resId);
    }
}